#include "stdafx.h"
#include <Windows.h>

LPTSTR SlotName;

BOOL WriteSlot(HANDLE hSlot, char* msg)
{
   BOOL fResult; 
   DWORD cbWritten; 
 
   fResult = WriteFile(hSlot, 
     msg, 
     (strlen(msg)+1)*sizeof(TCHAR),  
     &cbWritten, 
     (LPOVERLAPPED) NULL); 
 
   if (!fResult) 
   { 
      printf("WriteFile failed with %d.\n", GetLastError()); 
      return FALSE; 
   } 
 
   //printf("Slot written to successfully.\n"); 

   return TRUE;
}

bool bla()
{
	HANDLE hFile; 

	hFile = CreateFile(SlotName, 
		 GENERIC_WRITE, 
		 FILE_SHARE_READ,
		 (LPSECURITY_ATTRIBUTES) NULL, 
		 OPEN_EXISTING, 
		 FILE_ATTRIBUTE_NORMAL, 
		 (HANDLE) NULL); 
 
   if (hFile == INVALID_HANDLE_VALUE) 
   { 
      printf("CreateFile failed with %d.\n", GetLastError()); 
      return FALSE; 
   } 
 
   //WriteSlot(hFile, TEXT("Message one for mailslot."));
   //WriteSlot(hFile, TEXT("Message two for mailslot."));

   //Sleep(5000);

   //WriteSlot(hFile, TEXT("Message three for mailslot."));
 
   CloseHandle(hFile); 
   return true;
}